/*
Contains functions specific to drawing.

*/




void drawRect(float x, float y, int width, int height, float rotation){

    glPushMatrix();
        glTranslated(x,y,0);
        glRotatef(rotation+180,0,0,1);
        glScaled(width,height, 0);
        glBegin(GL_QUADS);
			glTexCoord2f(0.0f,0.0f); glVertex3f(.5f,-.5f,0.0f);
			glTexCoord2f(0.0f,1.0f); glVertex3f(.5f,.5f,0.0f);
			glTexCoord2f(1.0f,1.0f); glVertex3f(-.5f,.5f,0.0f);
			glTexCoord2f(1.0f,0.0f); glVertex3f(-.5f,-.5f,0.0f);
        glEnd();
	glPopMatrix();
}

void drawImage(float x, float y, std::string image, float rotation){
	TM()->setTexture(image);
    glPushMatrix();
        glTranslated(x,y,0);
        glRotatef(rotation+180,0,0,1);
        glScaled(TM()->getTextureWidth(image), TM()->getTextureHeight(image), 0);
        glBegin(GL_QUADS);
			glTexCoord2f(0.0f,0.0f); glVertex3f(.5f,-.5f,0.0f);
			glTexCoord2f(0.0f,1.0f); glVertex3f(.5f,.5f,0.0f);
			glTexCoord2f(1.0f,1.0f); glVertex3f(-.5f,.5f,0.0f);
			glTexCoord2f(1.0f,0.0f); glVertex3f(-.5f,-.5f,0.0f);
        glEnd();
	glPopMatrix();
}

void drawImageMask(float x, float y, std::string image, float rotation){
	glEnable(GL_BLEND);
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	TM()->setTexture(image);
    glPushMatrix();
        glTranslated(x,y,0);
        glRotatef(rotation+180,0,0,1);
        glScaled(TM()->getTextureWidth(image), TM()->getTextureHeight(image), 0);
        glBegin(GL_QUADS);
			glTexCoord2f(0.0f,0.0f); glVertex3f(.5f,-.5f,0.0f);
			glTexCoord2f(0.0f,1.0f); glVertex3f(.5f,.5f,0.0f);
			glTexCoord2f(1.0f,1.0f); glVertex3f(-.5f,.5f,0.0f);
			glTexCoord2f(1.0f,0.0f); glVertex3f(-.5f,-.5f,0.0f);
        glEnd();
	glPopMatrix();
}